<template>
	<view>
		<view @click="linkDetail(item.id)" class="news-item" v-for="item in list" :key="item.id">
			<image
				src="https://res.vmallres.com/pimages/uomcdn/CN/pms/202203/gbom/6941487250882/428_428_A1308212EBC5B717A9110FFF9906CC91mp.png"
				mode=""></image>
			<view class="right">
				<view class="title">
					{{item.title}}
				</view>
				<view class="info">
					<text>发表时间：{{item.add_time | formaDate}}</text>
					<text>浏览次数：{{item.click}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'newsList',
		props: ['list'],
		filters: {
			formaDate(date) {
				const ndate = new Date(date)
				const year = ndate.getFullYear()
				const month = ndate.getMonth().toString().padStart(2,0)
				const day = ndate.getDay().toString().padStart(2,0)
				return year + '-' + month + '-' + day
			}
		},
		methods:{
			linkDetail(id){
				this.$emit('itemClick',id)
			}
		}
	}
</script>

<style lang="scss">
	.news {
		.news-item {
			display: flex;
			padding: 10rpx 20rpx;
			border-bottom: 1px solid #CCCCCC;

			image {
				width: 200rpx;
				height: 150rpx;
				min-width: 200rpx;
				max-width: 200rpx;
			}

			.right {
				margin-left: 15rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.title {
					font-size: 30rpx;
				}

				.info {
					font-size: 24rpx;

					text:nth-child(2) {
						margin-left: 30rpx;
					}
				}
			}
		}
	}
</style>
